package org.example.utils;

public class ThreadLocalUtil {

    //提供一个ThreadLocal对象，用于存储当前线程的用户信息
    private static final ThreadLocal THREAD_LOCAL = new ThreadLocal<>();

    //提供键获取值
    public static <T> T get(){
        return (T) THREAD_LOCAL.get();
    }

    //存储键值
    public static void set(Object value){
        THREAD_LOCAL.set(value);
    }

    //移除键值,防止内存泄漏
    public static void remove(){
        THREAD_LOCAL.remove();
    }
}
